<?php
namespace Amis\form;
class InputTree extends FormItem
{
    public string $type = 'input-tree';

    public function options($options)
    {
        $this->options = $options;
        return $this;
    }

    public function source($api)
    {
        $this->source = $api;
        return $this;
    }

    public function autoComplete(string $autoComplete)
    {
        $this->autoComplete = $autoComplete;
        return $this;
    }

    public function multiple(bool $multiple = false)
    {
        $this->multiple = $multiple;
        return $this;
    }

    public function delimiter($delimiter = false)
    {
        $this->delimiter = $delimiter;
        return $this;
    }

    public function labelField(string $labelField = 'label')
    {
        $this->labelField = $labelField;
        return $this;
    }

    public function valueField(string $valueField = 'value')
    {
        $this->valueField = $valueField;
        return $this;
    }

    public function iconField(string $iconField = 'icon')
    {
        $this->iconField = $iconField;
        return $this;
    }

    public function joinValues(bool $joinValues = true)
    {
        $this->joinValues = $joinValues;
        return $this;
    }

    public function extractValue(bool $extractValue = false)
    {
        $this->extractValue = $extractValue;
        return $this;
    }

    public function creatable(bool $creatable = false)
    {
        $this->creatable = $creatable;
        return $this;
    }

    public function addControls(array $addControls)
    {
        $this->addControls = $addControls;
        return $this;
    }

    public function addApi(string $addApi)
    {
        $this->addApi = $addApi;
        return $this;
    }

    public function editable(bool $editable = false)
    {
        $this->editable = $editable;
        return $this;
    }

    public function editControls(array $editControls)
    {
        $this->editControls = $editControls;
        return $this;
    }

    public function editApi(string $editApi)
    {
        $this->editApi = $editApi;
        return $this;
    }

    public function removable(bool $removable = false)
    {
        $this->removable = $removable;
        return $this;
    }

    public function deleteApi(string $deleteApi)
    {
        $this->deleteApi = $deleteApi;
        return $this;
    }

    public function searchable(bool $searchable = false)
    {
        $this->searchable = $searchable;
        return $this;
    }

    public function hideRoot(bool $hideRoot = true)
    {
        $this->hideRoot = $hideRoot;
        return $this;
    }

    public function rootLabel(string $rootLabel = '顶级')
    {
        $this->rootLabel = $rootLabel;
        return $this;
    }

    public function showIcon(bool $showIcon = true)
    {
        $this->showIcon = $showIcon;
        return $this;
    }

    public function showRadio(bool $showRadio = false)
    {
        $this->showRadio = $showRadio;
        return $this;
    }

    public function initiallyOpen(bool $initiallyOpen = true)
    {
        $this->initiallyOpen = $initiallyOpen;
        return $this;
    }

    /**
     * 设置默认展开的级数，只有initiallyOpen不是true时生效。
     * @param int $unfoldedLevel
     * @return $this
     */
    public function unfoldedLevel(int $unfoldedLevel = 0)
    {
        $this->unfoldedLevel = $unfoldedLevel;
        return $this;
    }

    public function autoCheckChildren(bool $autoCheckChildren = true)
    {
        $this->autoCheckChildren = $autoCheckChildren;
        return $this;
    }

    /**
     * autoCheckChildren为true时生效；默认行为：子节点禁用，值只包含父节点值；设置为true时，子节点可反选，值包含父子节点值。
     * @param bool $cascade
     * @return $this
     */
    public function cascade(bool $cascade = false)
    {
        $this->cascade = $cascade;
        return $this;
    }

    /**
     * cascade为false时生效，选中父节点时，值里面将包含父子节点的值，否则只会保留父节点的值。
     * @param bool $withChildren
     * @return $this
     */
    public function withChildren(bool $withChildren = false)
    {
        $this->withChildren = $withChildren;
        return $this;
    }

    /**
     * autoCheckChildren为true时生效，不受cascade影响；onlyChildren为true，ui行为级联选中子节点，子节点可反选，值只包含子节点的值。
     * @param bool $onlyChildren
     * @return $this
     */
    public function onlyChildren(bool $onlyChildren = false)
    {
        $this->onlyChildren = $onlyChildren;
        return $this;
    }

    /**
     * 是否可以创建顶级节点
     * @param bool $rootCreatable
     * @return $this
     */
    public function rootCreatable(bool $rootCreatable = false)
    {
        $this->rootCreatable = $rootCreatable;
        return $this;
    }

    /**
     * 创建顶级节点的悬浮提示
     * @param string $rootCreateTip
     * @return $this
     */
    public function rootCreateTip(string $rootCreateTip = '添加一级节点')
    {
        $this->rootCreateTip = $rootCreateTip;
        return $this;
    }

    /**
     * 最少选中的节点数
     * @param int $minLength
     * @return $this
     */
    public function minLength(int $minLength)
    {
        $this->minLength = $minLength;
        return $this;
    }

    /**
     * 最多选中的节点数
     * @param int $maxLength
     * @return $this
     */
    public function maxLength(int $maxLength)
    {
        $this->maxLength = $maxLength;
        return $this;
    }

    /**
     * tree 最外层容器类名
     * @param string $treeContainerClassName
     * @return $this
     */
    public function treeContainerClassName(string $treeContainerClassName)
    {
        $this->treeContainerClassName = $treeContainerClassName;
        return $this;
    }

    /**
     * 是否开启节点路径模式
     * @param bool $enableNodePath
     * @return $this
     */
    public function enableNodePath(bool $enableNodePath = false)
    {
        $this->enableNodePath = $$enableNodePath;
        return $this;
    }

    /**
     * 节点路径的分隔符，enableNodePath为true时生效
     * @param string $pathSeparator
     * @return $this
     */
    public function pathSeparator(string $pathSeparator = '/')
    {
        $this->pathSeparator = $$pathSeparator;
        return $this;
    }
}